#include <stdio.h>
#include "ini_parser.h"

int main()
{
	PSIniFile pstIniFile = init_pstCreate();
	if(NULL == pstIniFile) {
		return 0;
	}

	if(0 != ini_iLoadFromFile(pstIniFile, "data.ini") ) {
		return 0;
	}
	
	printf("%s\n", ini_pcGetItemString(pstIniFile, "global", "username", ""));
	printf("%s\n", ini_pcGetItemString(pstIniFile, "global", "name", "jian"));
	printf("%s\n", ini_pcGetItemString(pstIniFile, "glo", "username", "huang"));
	printf("%s\n", ini_pcGetItemString(pstIniFile, "s s s", "lala  lala", "failed"));


	ini_iPutItemString(pstIniFile, "global_add", "username", "xiaokk");
	ini_iPutItemString(pstIniFile, "space test", "pass word", "123 456");
	ini_iPutItemString(pstIniFile, "section", "test_username", "xiaokk");
	ini_iSaveToFile(pstIniFile, "data2.ini");


    ini_vRemoveSect(pstIniFile, "section");
    ini_vRemoveItem(pstIniFile, "global_add", "username");
	ini_iSaveToFile(pstIniFile, "data3.ini");


    int_iPutItemInteger(pstIniFile, "all", "username", 1234324);
    int_iPutItemInteger(pstIniFile, "all", "user", 1234);
    int_iPutItemInteger(pstIniFile, "all", "usernamePwd", 321);
	ini_iSaveToFile(pstIniFile, "data4.ini");


	printf("%d\n", ini_iGetItemInteger(pstIniFile, "all", "username", 0));

	ini_vClear(pstIniFile);
	return 0;
}





/*
int main()
{
	SList *pstList = JList_pstCreate();
	for (int i=1; i<10; i++)
	{
		JList_add(pstList, (void*)i);
	}
	printf("iNum: %d\n", pstList->m_iNum);

	SListNode * pstHead = pstList->m_pstHead->m_pstNext;
	while (NULL != pstHead)
	{
		printf("%d ", (int)pstHead->m_pvData);
		pstHead = pstHead->m_pstNext;
	}
	printf("\n");

	JList_del(pstList, 3);
	JList_del(pstList, 1);

	JList_print(pstList);

	JList_free(pstList);
	return 0;
}
*/
